package cn.cimoc.config.security;

import cn.cimoc.util.MD5Utils;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;


@Component
public class MyPasswordEncoder implements PasswordEncoder {
    @Override
    public String encode(CharSequence rawPassword) {
        return MD5Utils.encode(rawPassword.toString());
    }

    @Override
    public boolean matches(CharSequence rawPassword, String encodedPassword) {
        // encodedPassword 是数据库的密码
        // rawPassword 是前端发过来的明文密码
        return encode(rawPassword).equals(encodedPassword);
    }
}
